class SideGame extends egret.Sprite{
	public correctWai:egret.Bitmap;//外卖 
	public errWai:egret.MovieClip;//错误的外卖
	public errWai1:egret.Bitmap;//抛物线的外卖
	public cullet:egret.MovieClip;//碎玻璃
	public redBox=RES.getRes("redBox_png");//红色按钮汉堡
	public grenBox=RES.getRes("grenBox_png");//绿色按钮沙拉
	public yelBox=RES.getRes("yelBox_png");//黄色按钮披萨
	public spend=3;//移动速度
	private timers:egret.Timer = new egret.Timer(10,0);//定时器移动错误的餐盒
	public constructor() {
		super();
		this.creatWai(); 
	};
	// 外卖
	private creatWai() {
		// 正确餐盒
		this.correctWai = new egret.Bitmap();
		this.correctWai.texture = RES.getRes("comestiblebox_png");
		this.correctWai.width = 40;
		this.correctWai.height = 45;
		this.correctWai.visible = false;
		this.addChild(this.correctWai);

		// 错误餐盒
		this.errWai1 = new egret.Bitmap();
		this.errWai1.texture = RES.getRes("comestible_png");
		this.errWai1.width = 40;
		this.errWai1.height = 45;
		this.errWai1.x=113;
		this.errWai1.y=400;
		this.errWai1.visible = false;
		this.addChild(this.errWai1);
		
		// 盒子落地动画
		var can  = RES.getRes("food_json");
		var canCont:egret.Texture = RES.getRes("food_png");
		var canBox:egret.MovieClipDataFactory = new egret.MovieClipDataFactory( can, canCont );
		this.errWai = new egret.MovieClip( canBox.generateMovieClipData( "food" ) );
		this.errWai.scaleX =0.3;
		this.errWai.scaleY= 0.3;
		// this.errWai.gotoAndPlay("start",0);
		this.errWai.visible = false;
		this.addChild(this.errWai);

		// 碎玻璃动画
		var data  = RES.getRes("boli_json");
		var text:egret.Texture = RES.getRes("boli_png");
		var mcFactory:egret.MovieClipDataFactory = new egret.MovieClipDataFactory( data, text );
		this.cullet = new egret.MovieClip( mcFactory.generateMovieClipData( "boli" ) );
		this.cullet.scaleX =0.3;
		this.cullet.scaleY= 0.3;
		this.cullet.visible=false;
		this.addChild(this.cullet);
		// this.cullet.gotoAndPlay("start",0);
	};
	// 定时器打开
	public sideTime(){
		this.timers.addEventListener(egret.TimerEvent.TIMER,this.scoreERR,this);
		this.timers.start();
	};
	// 错误餐盒移动
	private scoreERR(){ 
		
		if(this.errWai.y < 600){
			this.errWai.y += this.spend;
		}else{
			this.errWai.visible = false;
			this.timers.stop;
			// console.log("消失")
			this.timers.removeEventListener(egret.TimerEvent.TIMER,this.scoreERR,this);
		}
	};
}